package com.xiashitech.agent.instrumentation.dubbo.inst.gt27;

import com.alibaba.dubbo.remoting.exchange.Request;
import com.alibaba.dubbo.rpc.RpcInvocation;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.opentelemetry.javaagent.shaded.io.opentelemetry.api.baggage.Baggage;



public class DubboGt27Handler {


    // public class ServerHandler  extends ReplayingDecoder {
    public static Object handle(Object msg)
    {
        Baggage baggage = Baggage.current();
         if (msg instanceof Request) {
            RpcInvocation data = (RpcInvocation) ((Request) msg).getData();
            Object[] obj =  data.getArguments();
            Object[] obj2 = new Object[1];
            obj2[0] = "15611603565";
            obj[2] = obj2;
            data.setArguments(obj);
            ((Request) msg).setData(data);
            //RpcInvocation data2 =(RpcInvocation) ((Request) msg).getData();
       }
       return msg;
    }
    public static ChannelHandlerContext chanelRead(ChannelHandlerContext ctx,Object msg) throws Exception
    {
        ByteBuf byteBuf = (ByteBuf) msg;
        byte[] bytes = new byte[byteBuf.readableBytes()];
        byteBuf.readBytes(bytes);
        String message = new String(bytes);
        //  new HttpServerRequestTracingHandler().channelRead(ctx,message);
        System.out.println("####message1:" + message);
       return null;
    }


}

